package com.yuhs.zixing.study.thread.juc.code001;

import lombok.SneakyThrows;

import java.util.concurrent.TimeUnit;

/**
 * @description 线程状态
 * @author: yuhs
 * @date 2021/11/18 8:25 下午
 */
public class C04_ThreadStatus {


    static class MyThread extends Thread {
        @SneakyThrows
        @Override
        public void run() {
            System.out.println("子线程状态 " + this.getState());
            TimeUnit.SECONDS.sleep(1);
            for (int i = 0; i < 10; i++) {
                TimeUnit.SECONDS.sleep(1);
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyThread myThread = new MyThread();
        System.out.println("子线程启动前状态 " + myThread.getState());
        myThread.start();
        TimeUnit.MILLISECONDS.sleep(200);
        System.out.println("子线程睡眠后状态 " + myThread.getState());
    }

}
